<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>
    <script src="https://www.layuicdn.com/auto/layui.js" v="2.5.6" e="layui"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/mobile/need/layer.css" rel="stylesheet">
    <link rel="stylesheet" href="static/css/style.css">
    <script src="https://cdn.bootcss.com/vue/2.5.10/vue.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="static/js/jquerysession.js"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <!--顶栏-->
    <div class="layui-header">
        <div class="layui-logo">会员后台</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->


        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img"><span id="uname"></span>
                </a>

            </li>
            <li class="layui-nav-item"><a href="/index.html">退出登录</a></li>
        </ul>
    </div>
    <!--<header>
        <div style="float: right">
            <i  class="layui-icon  layui-anim layui-anim-rotate layui-anim-loop" style="font-size: 30px; color: #969baa;">&#xe614;</i>&nbsp; &nbsp; &nbsp;
        </div>
    </header>-->

    <div class="main" id="bc">
        <!--左栏-->
        <div class="cai">
            <ul class="cl" >
                <!--顶级分类-->
                <li v-for="vo,index in menu" :class="{hidden:vo.hidden}">
                    <a href="javascript:;"  :class="{active:vo.active}"  @click="onActive(index)">
                        <i class="layui-icon" v-html="vo.icon"></i>
                        <span v-text="vo.name"></span>
                        <i class="layui-icon arrow" v-show="vo.url.length==0">&#xe61a;</i> <i v-show="vo.active" class="layui-icon active">&#xe623;</i>
                    </a>
                    <!--子级分类-->
                    <div v-for="vo2,index2 in vo.list">
                        <a href="javascript:;" :class="{active:vo2.active}" @click="onActive(index,index2)" v-text="vo2.name"></a>
                        <i v-show="vo2.active" class="layui-icon active">&#xe623;</i>
                    </div>
                </li>
            </ul>
        </div>
        <!--右侧-->
        <div class="right">
                <form class="layui-form layui-form-pane" action="" method="post" lay-filter="dataFrm" id="dataFrm">
                    <div class="layui-form-item">
                        <label class="layui-form-label">账号</label>
                        <div class="layui-input-block">
                            <input type="text" name="uname" id="uname1" readonly style="background: #E0E0E0" autocomplete="off" placeholder="请输入标题" class="layui-input" >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户名</label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" id="name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">电话</label>
                            <div class="layui-input-dv">
                                <input type="text" name="u_phone"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">性别</label>
                            <div class="layui-input-dv">
                            <select name="sex" lay-verify="">
                                <option value="男">男</option>
                                <option value="女">女</option>
                            </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">年龄</label>
                            <div class="layui-input-dv">
                                <input type="text" name="age"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">邮箱</label>
                            <div class="layui-input-block">
                                <input type="text" name="email"  autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">积分</label>
                            <div class="layui-input-dv">
                                <input type="text" name="integral" readonly style="background: #E0E0E0" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="button" class="layui-btn" lay-submit="" lay-filter="btn">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>



        </div>
    </div>
</div>
<script>
    layui.use(['element','layer','table','form'],function(){
        var element = layui.element;
        var layer=layui.layer;
        var table=layui.table;
        var form=layui.form;






        $(function(){
            var uname = $.session.get('uname')
            $("#uname").html(uname);
            $.ajax({
                type: "post",
                url: "/user/selectByname",
                data: {'uname': uname},
                success:function (data){
                    var name='';
                    var uname='';
                    var u_phone='';
                    var sex='';
                    var email='';
                    var integral='';
                    var age='';
                    $.each(JSON.parse(data),function (i,n){
                        uname=n.uname;
                        name=n.name;
                        u_phone=n.u_phone;
                        sex=n.sex;
                        email=n.email;
                        integral=n.integral;
                        age=n.age;
                    })
                    form.val('dataFrm', {
                        "uname": uname // "name": "value"
                        ,"name": name
                        ,"u_phone": u_phone
                        ,"sex": sex //复选框选中状态
                        ,"age": age //开关状态
                        ,"email": email
                        ,"integral": integral
                    });
                }

            })
        })

        form.on('submit(btn)', function (obj) {
            var params = $("#dataFrm").serialize();
            params = decodeURIComponent(params, true);
            $.ajax({
                type: "post",
                url: "/user/updateuser",
                data: params,
                success: function (data) {
                    if (data.trim() === "1") {
                        setTimeout('window.location.reload()', 500);
                        layer.msg("修改成功")
                    } else {
                        layer.msg("失败")
                    }
                }
            })
        })

    })

</script>

<script src="static/js/config.js"></script>
<script src="static/js/script.js"></script>
</body>
</html>